using System;
using System.Collections.Generic;
using System.Text;
using Hermes.Framework.FileSystem;
using NUnit.Framework;

namespace Hermes.Framework.Test
{
    [TestFixture]
    public class UrlTest
    {
        protected Url url1 = null, url2, url3;

        public UrlTest()
        {
            url1 = new Url("ftp://192.168.1.1:21/hello/world.txt");
            url2 = new Url("http://192.168.1.1/hello/");
            url3 = new Url("https://localhost:1234/");
        }

        [Test]
        public void TestProtocol()
        {
            Console.WriteLine(url1.Protocol);
            Assert.AreEqual("ftp", url1.Protocol);
            Assert.AreEqual("http", url2.Protocol);
            Assert.AreEqual("https", url3.Protocol);
        }

        [Test]
        public void TestHost()
        {
            Console.WriteLine(url1.Host);
            Assert.AreEqual("192.168.1.1", url1.Host);
            Assert.AreEqual("192.168.1.1", url2.Host);
            Assert.AreEqual("localhost", url3.Host);
        }

        [Test]
        public void TestPort()
        {
            Console.WriteLine(url1.Port);
            Assert.AreEqual(21, url1.Port);
            Assert.AreEqual(0, url2.Port);
            Assert.AreEqual(1234, url3.Port);
        }

        [Test]
        public void TestDirectory()
        {
            Console.WriteLine(url1.Directory);
            Assert.AreEqual("hello", url1.Directory);
            Assert.AreEqual("hello", url2.Directory);
            Assert.AreEqual("/", url3.Directory);
        }

        [Test]
        public void TestFile()
        {
            Console.WriteLine(url1.File);
            Assert.AreEqual("world.txt", url1.File);
            Assert.AreEqual("", url2.File);
            Assert.AreEqual("", url3.File);
        }
    }
}
